package com.lsz.crm.utils;

import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Base64;

/**
 * 编码 md5 码工具类
 */

public class Md5Util {
	
	public static String encode(String msg){
		try {
			// 得到 MD5 码的实例
			MessageDigest messageDigest= MessageDigest.getInstance("md5");
			return Base64.getEncoder().encodeToString(messageDigest.digest(msg.getBytes())) ;
		}catch (Exception e){
			e.printStackTrace();
			return null;
		}
	}

	public static void main(String[] args) {
		String msg = "admin123456";
		System.out.println(Arrays.toString(msg.getBytes()));
		System.out.println(encode(msg));
	}

}
